class Plugin{
  constructor(matchs, js, className){
    this.matchs = matchs;
    this.js = js;
    this.className = className;
    this.loadJs();
  }

  register() {
    for(let plugin of this.plugins) {
      console.log(plugin);
    }
  }

  // 加载js
  loadJs() {
    Registry.loadFile(js);
  }

  search(query, callback) {
    console.log(this.plugins);
    for(let plugin of this.plugins) {
      console.log(plugin.class_name);
      // const p = new Function(`return ${plugin.class_name}`)();
      // console.log(window[plugin.class_name]);
      const c = Registry.getClass(plugin.class_name);
      const p = new c();
      // const p = eval(`new ${plugin.class_name}()`);
      console.log(p);
      try {
        p.fetchSearchResults(query).then((result) => {
          console.log(result);
          // fetchNum--;
          if(callback) callback(result);
        });
      } catch(e) {
        // console.log(e);
      }

    }
  }
}